﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using DomainDriver.DomainModeling.DataProviders;
using DomainDriver.DomainModeling.Repositories;
using DomainDriver.DomainModeling.GenericUnitTesting.Constraints;
using AutomotivePricingModel.Brands;
using AutomotivePricingModel.Countries;

namespace AutomotivePricingModel.UnitTests.ParentChildConstraints
{
    [TestFixture(new object[] { DataSourcePersistenceType.None })]
    [TestFixture(new object[] { DataSourcePersistenceType.File })]
    [TestFixture(new object[] { DataSourcePersistenceType.Database })]
    public class CountryBrandParentChildConstraintTests : ParentChildConstraintTestFixture<AutomotivePricingDomainModel, Guid, Guid, Country, Brand>
    {
        public CountryBrandParentChildConstraintTests(DataSourcePersistenceType persistenceType)
            : base(persistenceType)
        {
            // do nothing
        }

        protected override AutomotivePricingDomainModel CreateDomainModel(DataSourcePersistenceType persistenceType, bool buildModelWithConstraints)
        {
            AutomotivePricingDomainModel model = new AutomotivePricingDomainModel(persistenceType, buildModelWithConstraints);
            return model;
        }

        protected override Country CreateParent(ref bool parentAlreadyAdded)
        {
            parentAlreadyAdded = false;
            Country parent = CreateFakeParent();
            return parent;
        }

        protected override Country CreateFakeParent()
        {
            Country parent = new Country();
            parent.Name = parent.Key.ToString();
            return parent;
        }

        protected override Brand CreateChild()
        {
            Brand child = new Brand();
            child.Name = child.Key.ToString();
            return child;
        }

        protected override void AssignParentToChild(Guid parentKey, Brand child)
        {
            child.CountryOfOrigin = parentKey;
        }
    }
}